import request from '@/config/axios'

// 商家授信管理 VO
export interface MerchantCreditVO {
  id: number // 主键ID
  merchantId: number // 商家ID
  accountId: string // 账户ID
  creditType: number // 授信类型
  creditAmount: number // 授信额度
  creditRatio: number // 授信比例
  creditStatus: number // 授信状态
  lastCreditUpdateTime: Date // 上次授信更新时间
  status: number // 状态
}

// 商家授信管理 API
export const MerchantCreditApi = {
  // 查询商家授信管理分页
  getMerchantCreditPage: async (params: any) => {
    return await request.get({ url: `/juliang/merchant-credit/page`, params })
  },

  // 查询商家授信管理详情
  getMerchantCreditById: async (id: number) => {
    return await request.get({ url: `/juliang/merchant-credit/getById?id=` + id })
  },

  // 新增商家授信管理
  createMerchantCredit: async (data: MerchantCreditVO) => {
    return await request.post({ url: `/juliang/merchant-credit/create`, data })
  },

  // 修改商家授信管理
  updateMerchantCredit: async (data: MerchantCreditVO) => {
    return await request.post({ url: `/juliang/merchant-credit/update`, data })
  },

  // 修改商家授信管理状态
  updateMerchantCreditStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/juliang/merchant-credit/updateStatus`, data: data })
  },

  // 删除商家授信管理
  deleteMerchantCreditById: async (id: number) => {
    return await request.get({ url: `/juliang/merchant-credit/delete?id=` + id })
  },

  // 导出商家授信管理 Excel
  exportMerchantCredit: async (params) => {
    return await request.download({ url: `/juliang/merchant-credit/export-excel`, params })
  },
}
